//
//  EconomicCalendar.cpp
//  Chart
//
//  Created by CaoJun on 15/1/22.
//
//

#include "EconomicCalendar.h"

//
//  MACD.cpp
//  Chart
//
//  Created by ma xiaoyang on 6/18/13.
//
//

#include "EconomicCalendar.h"
#include "Rectangle.h"
#include "YTXChartStyle.h"

#include <vector>
#include <string>
#include <cmath>

using namespace ytx;
using namespace std;

EconomicCalendar::EconomicCalendar(IndexConfig indexConfig):IndexData(indexConfig, 2){
    type = QuotationType::EconomicCalendar;
    indexName = "EconomicCalendar";
    this->setColumn(Rect(0,0,0));
    this->setRow(Rect(0,0,0));
}

EconomicCalendar::~EconomicCalendar()
{

}


void EconomicCalendar::calculate(Quotation * data)
{
    AVGData * avgData = (AVGData *) data;
    economicCalendarData = avgData->getEconomicCalendarDataList();
}


bool EconomicCalendar::hasData() const
{
    return economicCalendarData.size() > 0;
}

bool EconomicCalendar::hasData(int index) const
{

    if (hasData())
    {
        int count = (int)economicCalendarData.size();
        return 0 <= index && index < count;
    }
    else{
        return false;
    }
}

bool EconomicCalendar::hasCrosshairsYData() const
{
    return false;
}


string EconomicCalendar::getCrosshairYData(int index)
{
    return "";
}


pair<double, double> EconomicCalendar::getAdjustedDataMinMax(int startIndex, int endIndex, const Rectangle & rect) const
{
    return make_pair(0, 0);
}

std::vector<std::pair<double, std::string> > EconomicCalendar::getLeftSideText(int startIndex, int endIndex, const Rectangle & rect, const Style & style) const
{
    vector<pair<double, string> > ret;
    return ret;
}


std::vector<std::pair<std::string, std::string> > EconomicCalendar::getTopSideText(const std::vector<std::vector<double> > & data, int index) const
{
    vector<pair<string, string> > ret;
    return ret;
}

pair<string, string> EconomicCalendar::getTopSideInfoText() const
{
    return make_pair("", "");
}

void EconomicCalendar::initInfo(Quotation * data){
    id = data->getId();
    quotationType = data->getQuotationType();
    drawingCount = data->drawingCount;
    parentData = data;
}

int EconomicCalendar::getDataLength() const
{
    return (int)economicCalendarData.size();
}